from django.conf.urls.defaults import *
from django.contrib.comments.models import Comment
from models import Entry
from tagging.models import Tag
from tagging.views import tagged_object_list
import views

info_dict = {
    'queryset': Entry.objects.filter(status=Entry.LIVE_STATUS),
    'date_field': 'pub_date',
}

entry_tag_dict = {
    'queryset': Entry.objects.filter(status=Entry.LIVE_STATUS),
    'date_field': 'pub_date',
    'extra_context': { 'tag_list': Tag.objects.all(), } 
}

urlpatterns = patterns('',
                       (r'^category/(?P<slug>[-\w]+)/$', 'zblog.views.entry_by_category'),
                       (r'^comments/', include('django.contrib.comments.urls')),
                       (r'^tags/$', 'django.views.generic.list_detail.object_list', 
                                        dict(queryset=Tag.objects.all(), 
                                             paginate_by=100, 
                                             template_name='zblog/tag_list.html')),
                        (r'^tags/(?P<tag>[^/]+)/$', tagged_object_list, 
                                        dict(queryset_or_model=Entry.objects.filter(status=Entry.LIVE_STATUS), 
                                             paginate_by=10, 
                                             allow_empty=True, 
                                             template_name='zblog/entry_by_tag.html')),
                        (r'^entry/(?P<id>\w+)/*$', views.entry_by_id),
)


urlpatterns += patterns('django.views.generic.date_based',
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\w-]+)/$', 'object_detail', dict(info_dict, slug_field='slug')),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'archive_day', info_dict),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', info_dict),
    (r'^(?P<year>\d{4})/$', 'archive_year', info_dict),
    (r'^/?$', 'archive_index', entry_tag_dict),  

)